package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.model.Circle;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.dao.CircleMapper;
import com.yami.shop.service.CircleService;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class CircleServiceImpl extends ServiceImpl<CircleMapper, Circle> implements CircleService {

    @Override
    public void insertCircleInfo(Circle circle) throws IOException {
        //敏感词过滤
//        SensitiveWordUtil instance = SensitiveWordUtil.getInstance();
//        String a = "";
//        int num = instance.CheckSensitiveWord(a, 0, 1);
        this.save(circle);
    }

    @Override
    public IPage<Circle> pageCircleList(PageParam<Circle> page, Circle circle) {

        LambdaQueryWrapper<Circle> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Circle::getUserId,circle.getUserId());
        lambdaQueryWrapper.eq(Circle::getStatus,1);
        lambdaQueryWrapper.orderByDesc(Circle::getCreateTime);
        IPage<Circle> page1 = this.page(page, lambdaQueryWrapper);
        return page1;
    }


}
